package com.youlu.campus.service.mail;

import com.youlu.campus.wechat.service.impl.MerchantComplaintService;
import com.youlu.campus.entity.VO.req.DingTalkRobotRequest;
import com.youlu.campus.service.dingtalk.DingTalkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
public class MailService {

    //注入MailSender
    @Resource
    private JavaMailSender javaMailSender;

    @Resource
    private MerchantComplaintService merchantComplaintService;

    @Resource
    private DingTalkService dingTalkService;


    public void sendMail(){
        Long count = merchantComplaintService.queryComplaintPending();
        if(count==0){
            return;
        }
        DingTalkRobotRequest dingTalkRobotRequest = new DingTalkRobotRequest();
        dingTalkRobotRequest.setContent(count.toString());
        dingTalkService.sendPayComplaintMsg(dingTalkRobotRequest);
//        String text = "当前累积待处理"+count+"单";
//
//        SimpleMailMessage mailMessage = new SimpleMailMessage();
//        mailMessage.setFrom("gqgood202007@126.com");
//        mailMessage.setTo("liuyun@gqgood.com","295400085@qq.com");
//        mailMessage.setSubject("【"+text+"】");
//        mailMessage.setText(text);
//        javaMailSender.send(mailMessage);
    }
}
